﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;

using DataAccessLibrary;
using Windows.UI.Core;

// https://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x804 上介绍了“空白页”项模板

namespace Account
{
    /// <summary>
    /// 可用于自身或导航至 Frame 内部的空白页。
    /// </summary>
    public sealed partial class MainPage : Page
    {
        public static Frame ContentFrame { get; set; }

        public MainPage()
        {
            this.InitializeComponent();
            ContentFrame = MainFrame;
            MainFrame.Navigate(typeof(Details));
        }

        private void MenuBtn_Click(object sender, RoutedEventArgs e) => this.chromeSplitView.IsPaneOpen = !this.chromeSplitView.IsPaneOpen;

        private void AddRecordButton_Click(object sender, RoutedEventArgs e)
        {
            NavigateToPage(typeof(AddRecord));
        }

        private void SettingsButton_Click(object sender, RoutedEventArgs e)
        {
            NavigateToPage(typeof(Setting));
        }

        private void ChartsButton_Click(object sender, RoutedEventArgs e)
        {
            NavigateToPage(typeof(Charts));
        }

        private void FindButton_Click(object sender, RoutedEventArgs e)
        {
            NavigateToPage(typeof(Find));
        }

        private void DetailsButton_Click(object sender, RoutedEventArgs e)
        {
            NavigateToPage(typeof(Details));
        }

        private static void NavigateToPage(Type pageType)
        {
            if (ContentFrame.Content.GetType() != pageType) {
                ContentFrame.Navigate(pageType);
                SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Visible;
            }
        }
    }
}
